import request from '@/utils/request'
/**
 *登录请求=====================
 * @param {String} mobile 手机号
 * @param {String} code 验证码
 * @returns
 */
export const reqLogin = (mobile, code) => {
  return request({
    method: 'post',
    url: '/v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })
}
/**
 * 发送验证码请求===================
 * @param {String} mobile 手机号
 * @returns
 */
export const reqCode = (mobile) => request.get('/v1_0/sms/codes/' + mobile)
/**
 *
 * @returns 获取用户信息请求
 */
export const reqGetUser = () => {
  // const token = store.state.user.tokenInfo.token
  return request({
    method: 'get',
    url: '/v1_0/user/profile'
    // headers: {
    //   Authorization: 'Bearer ' + token
    // }
  })
}
/**
 * 属性token
 * @param {*} refreshToken  未过期的refresh_token
 * @returns
 */
export const reqRefreshToken = (refreshToken) => {
  return request({
    method: 'put',
    url: '/v1_0/authorizations',
    headers: {
      Authorization: `Bearer ${refreshToken}`
    }
  })
}
/**
 *
 * @returns 个人中心用户信息
 */
export const reqUserInfo = () => {
  return request({
    method: 'get',
    url: '/v1_0/user'
  })
}
/**
 *
 * @returns 个人资料
 */
export const reqProfileInfo = () => {
  return request({
    method: 'get',
    url: '/v1_0/user/profile'
  })
}
/**
 *
 * @param {*} formData 上传文件
 * @returns
 */
export const reqUpdatePhoto = (formData) => {
  return request({
    method: 'patch',
    url: '/v1_0/user/photo',
    data: formData
  })
}
/**
 *
 * @param {*} obj 编辑资料{
 * name:""
 * birthday:''
 * gender:''
 * }
 * @returns
 */
export const reqUpdateName = (obj) => {
  return request({
    method: 'patch',
    url: '/v1_0/user/profile',
    data: obj
  })
}
